How to use the Windows
Scripting Host
The WSH comes in two
versions - one for MS-DOS sessions, the other for the
Windows environment.
Using the MS-DOS version
 (August 1998).iso/full/W98Comp/IFace/wsh04.gif)
First open an MS-DOS window, then
type:
CSCRIPT scriptfile [WSH options]
[script options]
where:
scriptfile is the name of
the script to be executed, e.g. MyScript.vbs (VBScript
file names in .vbs, JavaScript file names end in .js).
WSH options control the
behaviour of the Windows Scripting Host while executing
the script. The options include:
//B |
Batch Mode: suppresses
display of prompts and error messages. |
//T:nn |
Time-out, i.e. the maximum
number of seconds the script can run. If omitted,
the script can run indefinitely |
//nologo |
Prevents display of the
WSH identification banner |
//H:Cscript |
Registers Cscript.exe as
the default application for running scripts |
//S |
Saves the current
command-line options for this user. |
//? |
Displays a help screen of
command details. |
Script Options are
parameters supplied to the script itself, e.g. file
names, dates etc. Each parameter is preceded by a single
/. Script options have no pre-determined format - these
are decided by the script's author.
Using the
Windows version of the scripting host.
The Windows version of the WSH is
called Wscript.exe, but you need never call it directly.
Instead, you can simply double-click on a script file
(with a .vbs or .js name extension), and Wscript.exe will
automatically load and run it (if this doesn't happen,
then WSH hasn't been installed properly on your system).
Creating and using script
control (.WSH) files.
You can also create control files
for scripts. These have a .WSH filename extension, and
provide an alternative to command-line WSH options (see
above), allowing you to manage items such as the maximum
time allowed for a script to run.
To create a
WSH file, right-click on the relevant script file (.js or
.vbs), choose Properties from the pop-up menu, then
choose the Script tab from the resulting dialog box.
Alter any of the properties on the dialog page, press OK,
and a .WSH file with the same name as the script will be
created. You can then double-click on the .WSH file
to load the script with your chosen options. .WSH files
can also be run by CSCRIPT.exe from an MS-DOS prompt.
.WSH files are
simple text files, and contain the same layout as Windows
.INI files. You can edit them with Windows Notepad or any
other text editor. By creating multiple versions of a
.WSH file, you can run the same script, but with
different parameters.
|